package com.xneure.test;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Sort {
	static char[] chars = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
			'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };

	 static FileOutputStream fos;
	static List<String> l = new ArrayList<String>(10000);

	public static void main(String[] args) throws Exception {
		 fos = new FileOutputStream("d:/java.txt");
//		char[] bs = "java算法测试".toCharArray();
//		for (char ch : chars) {
//			allPermutations(String.valueOf(ch), 1, 10);
//		}
//		for (int i = 0; i < bs.length; i++) {
//			String tmp = Integer.toHexString(bs[i]).toUpperCase();
//			tmp = fill(tmp,4);
//			System.out.println(tmp+"  "+l.indexOf(tmp));
//			
//		}
		 fos.flush();
		 fos.close();
	}

	public static void allPermutations(String c, int currLength, int length) throws IOException {
		if (currLength < length) {
			for (char ch : chars) {
				allPermutations(c + ch, currLength + 1, length);
			}
		} else {
			fos.write((c + "\r\n").getBytes());
			
//			l.add(c);
		}
	}

	public static String fill(String str, int l) {
		if (str.length() < l) {
			String tmp = "";
			for (int i = 0; i < l - str.length(); i++) {
				tmp += "0";
			}
			return tmp + str;
		}
		return str;
	}
}
